import java.util.*;

public class Test {

    public static int Max(int[] A,int left,int right) {
        int max = 0;
        for (int i = left; i <= right; i++) {
            max = Math.max(max,A[i]);
        }
        return max;
    }

    public static int findMaxGap(int[] A,int n) {
        //先定义一个变量记录一下最大值
        int m = 0;
        for (int i = 0; i <= n-2; i++) {
          m= Math.max(m,Math.abs(Max(A,0,i) - Max(A,i+1,n-1)));  //这里就要求一下数组中一段区间的最大值
        }
        return m;
    }
    public static void main(String[] args) {
        int[] A ={2,7,3,1,1};
        int n = A.length;

        int max1 = findMaxGap(A,n);
        System.out.println(max1);
    }
}
